<template>
	<view class="wf-box">
		<view class="head" :style="{ paddingTop: navBarHeight }">
			<view class="head-np">
				<view class="back" @click="back()">
					<image src="../../static/img/chat-09.png"></image>
				</view>
				<view class="title">选择好友</view>
				<view class="text" @click="to(1)">非好友转账</view>
			</view>
		</view>
		<view class="main" :style="{ paddingTop: navBarHeight }">
			<view class="item" v-for="item in list" @click="to(2,item)">
				<image :src="item.headImage"></image>
				<view>{{item.nickName}}</view>
			</view>
			<view class="text">{{list.length}}位联系人</view>
		</view>
	</view>
</template>

<script>
	import {
		friendListApi
	} from '@/api/api.js'
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		data() {
			return {
				list: ''
			}
		},
		mixins: [navBarMixin],
		onLoad(option) {
			this.friend()
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			to(type,e) {
				uni.navigateTo({
					url: '/pages/me/toFriend?info=' + JSON.stringify(e)+'&type='+type
				})
			},
			friend() {
				console.log('121212');
				friendListApi().then(res => {
					if (res.code == 0) {
						this.list = res.data
						// setTimeout(function() {
						// 	uni.navigateBack()
						// }, 2000)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 3000,
						})
					}
					console.log(res);
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		overflow: hidden;

		.back {
			image {
				width: 20rpx;
				height: 37rpx;
				position: absolute;
				left: 30rpx;
				top: 30rpx;
			}
		}

		.head {
			position: fixed;
			z-index: 333;
			width: 100%;
			background: #fff;

			.head-np {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 100%;
				height: 96rpx;
				padding: 0 30rpx;
				box-sizing: border-box;
				position: relative;

				.title {
					font-size: 36rpx;
					font-weight: bold;
				}

				.text {
					position: absolute;
					right: 30rpx;
					font-size: 24rpx;
					color: #3F93FF;
				}
			}
		}

		.main {
			// margin-top: 126rpx;
			// margin-top: 246rpx;
			margin: 196rpx 30rpx 60rpx;
			padding: 20rpx 30rpx 100rpx;
			background-color: white;

			.item {
				height: 110rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					width: 66rpx;
					height: 68rpx;
					margin-right: 20rpx;
				}

				view {
					flex: 1;
					height: 110rpx;
					line-height: 110rpx;
					border-bottom: 1rpx solid #EEEEEE;
				}
			}

			.text {
				font-size: 26rpx;
				color: #999999;
				text-align: center;
				margin-top: 30rpx;
			}
		}
	}
</style>